package org.samcolon.eeexplore.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description: redis测试web
 * @author: Sam.zhang
 * @date: 2021/12/13 - 1:36
 */
@Slf4j
@AllArgsConstructor
@RequestMapping("redis")
@RestController
@Api(tags = "redis测试web")
public class RedisController {
    @Resource
    private RedisTemplate redisTemplate;


    @GetMapping("/saveAndGet")
    @ApiOperation(value = "保存并且获得redis中的值")
    public ResponseEntity<?> saveAndGet(@RequestParam String key, @RequestParam String value) {
        redisTemplate.opsForValue().set(key, value);
        return ResponseEntity.ok(redisTemplate.opsForValue().get(key));
    }
}
